	PROGRAM PLOTTESTS
C *** LAST REVISED ON 10-SEP-1987 12:44:37.80
C *** SOURCE FILE: [DL.GRAPHICS.LONGLIB]PLOTTESTS.FOR
C
C	WRITTEN BY: DGL
C
C	THIS PROGRAM TESTS SOME OF THE LONGLIB MASTER PLOTTING ROUTINES
C	NOTE: ALTHOUGH THE "MASTER" ROUTINES HAVE A LOT OF OPTIONS ONLY
C	ONE OPTION FOR EACH ROUTINE WILL BE ILLUSTRATED.  THE PROGRAM WILL,
C	HOWEVER, TRY TO SHOW SOME OF THE UNIQUE THINGS THEY CAN EACH DO.
C	SINCE MANY MASTER ROUTINES HAVE SIMILAR GRID SPECS WE WILL TRY TO SHOW
C	ONE OF EACH KIND OF GRID.  WE WILL USE THE AUTO-SCALING OPTION MOST
C	OF THE TIME.
C
	DIMENSION X(125),Y(10),D(25,25),Y2(25,2),X2(25,2),Y3(25,3)
	DIMENSION XX(100),YY(100),XX2(300),YY2(300)
	DIMENSION ILINE(255),IP(100),ICOL(255)
	DATA TPI/3.141592654/,IS/9881821/
C
C	MASTER ROUTINE SCATPL COMMON BLOCK USED FOR ELLIPSE SCALLING, ETC.
C	AFTER THE CALL TO SCATPL -- ILLUSTRATES RETURNED SCALING USAGE.
C
	COMMON /CSCATPL/XMR,DXR,YMR,DYR
C
C	PIE CHART DATA
C
	CHARACTER*13 LABELS(7)
	DATA LABELS(1)/'Plot Routines'/
	DATA LABELS(2)/'Auxliary Rou.'/
	DATA LABELS(3)/'MASTER Routns'/
	DATA LABELS(4)/'MAP Routines '/
	DATA LABELS(5)/'Cursor Routns'/
	DATA LABELS(6)/'3D Plot Rou. '/
	DATA LABELS(7)/'Internal Rou.'/
	DIMENSION VALS(7),ISH(7),IWT(7)
	DATA VALS/51.,34.,-32.,6.,6.,21.,43./
	DATA ISH/0,1,2,3,4,5,6/
	DATA IWT/2,2,3,2,2,2,2/
C
C	INITIALIZE THE COLOR ARRAY (WE WILL ALWAYS USE
C	COLOR FOR THESE TESTS)
C
	DO 1 I=1,255
		ICOL(I)=I
1	CONTINUE
C
C	OPEN THE PLOT PACKAGE, USING PROMPTS FOR BOTH METAFILE AND SCREEN DEVICE
C	NOTE:  	FOR THESE TESTS WE WILL OPEN THE PLOT PACKAGE BEFORE THE
C		MASTER ROUTINE CALLS.  WE WILL SET THE IFLAG VALUES TO NOT
C		REOPEN THE PLOT PACKAGE AND ALSO TO LEAVE IS OPEN AFTER THE
C		THE CALL TO THEM.  THIS WILL ILLUSTRATE HOW MULTIPLE MASTER
C		ROUTINES CAN BE CALLED TOGETHER.
C
	CALL FRAME(0,0,1.0,1.0,1.0)
C
C	SET UP CLIPPING WINDOW WITHIN 11X8.5 INCH PAGE, THIS IS OPTIONAL
C	AND WILL RESULT IN CLIPPING OF PORTIONS OF PLOTTED LINES ETC.
C
	CALL PLOT(9.7,7.4,4)
C
C	PLOT A BOX AROUND THE CLIPPING WINDOW
C
	CALL RECT(-0.99,-0.99,9.69,7.39)
C
C	INITIALLY WE WILL PLOT A PAGE OF GRAPHICS OUTPUT EXAMPLES TO
C	ILLUSTRATE SOME MINOR ROUTINES AND THE WINDOW CLIPPING ABILITY
C
	CALL SYMBOL(5.1,4.85,0.2,'PLOTTESTS',0.0,9,-1)
	CALL SYMBOL(5.1,4.45,0.2,'Program',0.0,7,-1)
	CALL SYMBOL(5.1,4.0, 0.2,'MASTER',0.0,6,-1)
	CALL SYMBOL(5.1,3.6, 0.2,'Routines',0.0,8,-1)
C
C	ENCLOSE TITLE IN BOX WITH FAT SOLID LINE
C
	CALL NEWPEN(20)
	CALL PLOT(2.0,0.0,0)
	CALL RECT(4.8,3.45,7.3,5.35)
C
C	MAKE A VERY LARGE CIRCLE WHICH SHOULD BE CLIPPED OFF AT THE
C	PAGE/SCREEN EDGES
C
	CALL NEWPEN(-1)
	CALL CIRCLE(4.7,3.7,0.0,360.0,5.,5.0,0.0)
C
C	SHOW SOME MORE TEXT EXAMPLES IN DIFFERENT COLORS
C
	CALL PLOT(3.0,0.0,0)
	CALL SYMBOL(1.5,3.3,0.25,'SYMBOL Text ',45.0,11,-1)
	CALL PLOT(4.0,0.0,0)
	CALL SYMS(1.5,3.75,0.3,'SYMS Font 0 ',45.0,12,-1)
	CALL PLOT(5.0,0.0,0)
	CALL SYMS(-0.3,1.0,0.2,'|4SYMS Font 4 Text',90.0,18,-1)
C
C	SHOW AXES FOR SCALE AND ORIGIN LOCATION
C
	CALL AXIS3(-1.,0.,'X DIRECTION',11,13.,0.,-1.,12.,14.0104,
     $		-0.2,1002.)
	CALL AXIS3(0.,-1.,'Y DIRECTION',-1011,13.,90.,-1.,12.,
     $		14.0104,-0.2,1002.)
C
C	IDENTIFY LOCAL RELATIVE ORIGIN WITH LABEL AND ARROW
C
	CALL SYMBOL(0.5,0.5,.18,'RELATIVE ORIGIN (1,1)',0.,21,-1)
	CALL ARROW(0.45,0.5,0.6,-135.,0.12,45.0)
C
C	DRAW FULL CIRCLE WITH WIDE DOTTED LINE AND COLOR 7
C
	CALL NEWPEN(21)
	CALL PLOT(7.0,0.0,0)
	CALL CIRCLE(3.2,2.9,0.0,360.0,1.25,1.25,0.0)
C
C	DRAW SOME MORE STUFF SUCH AS A SPIRAL, TRIANGLE, AND A HEXAGON
C	WITH A UNIT WIDTH LINE TYPES
C
	CALL NEWPEN(-1)
	CALL PLOT(8.0,0.0,0)
	CALL CIRCLE(3.2,2.9,0.0,1600.0,0.2,1.0,0.0)
	CALL NEWPEN(3)
	CALL PLOT(3.2,3.7,3)
	CALL PLOT(2.5,2.4,2)
	CALL PLOT(3.95,2.4,2)
	CALL PLOT(3.2,3.7,2)
	CALL NEWPEN(2)
	CALL PLOT(9.0,0.0,0)
	CALL PLOT(2.05,2.35,3)
	CALL PLOT(2.05,3.45,2)
	CALL PLOT(3.2,4.15,2)
	CALL PLOT(4.35,3.45,2)
	CALL PLOT(4.35,2.35,2)
	CALL PLOT(3.2,1.65,2)
	CALL PLOT(2.05,2.35,2)
C
C	MAKE AN ARBITRARY REGION AND FILL IT IN USING SHADE, WE WILL
C	LABEL EXAMPLE USING NORMAL SOLID LINE TYPE AND COLOR 3 BUT SHADE
C	WITH COLOR 1
C
	CALL PLOT(3.,0.,0)
	CALL NEWPEN(0)
	CALL SYMBOL(6.2,2.9,.2,'SHADE EXAMPLE',0.,13,-1)
	X(1)=6.
	Y(1)=2.
	X(2)=7.2
	Y(2)=2.7
	X(3)=8.
	Y(3)=1.6
	X(4)=7.5
	Y(4)=0.5
	X(5)=6.2
	Y(5)=1.
	X(6)=6.5
	Y(6)=1.8
	X(7)=5.5
	Y(7)=1.
	X(8)=5.9
	Y(8)=2.
	CALL PLOT(1.0,0.0,0)
	CALL SHADE(X,Y,8,1,3,0.15,-30.,XX,1,0.,1.,0.,1.)
C
C	PROMPT USER FOR CLEAR SREEN, NOTE PEN UP COMMAND TO FORCE SCREEN
C	OUTPUT BEFORE THE PROMPT.  THEN SEND NEW PAGE COMMAND TO METAFILE
C
	CALL PLOT(0.0,0.0,3)
	CALL RTERM(2)
	CALL CTERM(2)
	CALL NEWPAGE
C
C	NOW PLOT MASTER ROUTINE EXAMPLES.
C	FIRST EXAMPLE WILL BE A FULL PAGE PIE CHART
C	SHOWING THE RELATIVE PROPORTIONS OF ROUTINE NAMES IN LONGLIB
C
	CALL PICHRT(3.,3.,2.0,0.25,-10002,-40.0,7,VALS,ISH,IWT,
     $		LABELS,13,0.12,+0.21,'LONGLIB Routines',16,0.2,
     $		0.1,D1,ICOL)
C
C	PROMPT FOR SCREEN CLEAR ON TERMINAL AND RAMTEK THEN FORCE
C	NEW METAFILE PAGE
C
	CALL CTERM(2)
	CALL RTERM(2)
	CALL NEWPAGE
C
C	FOR THE REMAINING MASTER ROUTINE EXAMPLES WE WILL DISPLAY SEVERAL
C	ROUTINES ON A SINGLE PAGE OF THE METAFILE
C	AND A SINGLE SCREEN OF THE RAMTEK, BUT LET'S PUT ONLY ONE PLOT PER
C	SCREEN ON THE VT100. THIS WILL ILLUSTRATE HOW TO USE MULTIPLE PLOT
C	OUTPUT DEVICES TOGETHER AND HOW TO SHIFT THE ORIGINS OF PLOTS.
C	THIS ILLUSTRATES HOW THE DIFFERENT DEVICE PACKAGES CAN BE INDEPENDENT
C
	CALL PLOT(0.0,-.3,-3)
	CALL FACTOR(.5)
	CALL VFACTOR(1.8)
	CALL PLOTVT(0.0,.2,-3)
C
C	PUT TERMINAL BACK INTO GRAPHICS MODE
C
	CALL CTERM(-1)
C
C	START WITH A SIMPLE TITLE
C
	CALL SYMBOL(7.,6.,.6,'CHART TITLE',0.,11,-1)
C
C	WITH A THICK-LINED BOX AROUND IT
C
	CALL NEWPEN(30)
	CALL RECT(6.8,5.8,13.4,6.8)
C
C	RESTORE NORMAL PENWIDTH
C
	CALL NEWPEN(0)
C
C	FILL SOME ARRAYS WITH DATA WE CAN PLOT, LET'S PICK SOME NICE FUNCTIONS
C	FIRST SOME ONE DIMENSIONAL DATA
C
	DO 2 J=1,25
		X(J)=J
		Y2(J,1)=J**2+5.
		Y2(J,2)=J
2	CONTINUE
C
C	THEN SOME TWO DIMENSIONAL
C
	DO 3 J=1,25
		DO 3 I=1,25
			D(J,I)=COS(TPI*FLOAT(J-1)/12.)*COS(TPI*FLOAT(I-1)/12.)
3	CONTINUE
C
C	SET UP A MAX,MIN PAIR FOR AN ILLUSTRATION
C
	D1=-1.
	D2=1.
C
C	EXAMPLE OF PLOTLG2 WITH A LOG/LOG SCALE AND GRIDE
C
	CALL PLOTLG2(X,Y2,2,25,-10073,5,6.,5.,'X AXIS',6,'Y AXIS',6,
     $		'PLOTLG2',-7,D1,D2,D3,D4,ICOL)
C
C	CHANGE LINE TYPE TO SOLID
C
	CALL NEWPEN(0)
C
C	MOVE ORIGIN ON SCREEN AND METAFILE/RAMTEK DIFFERENTLY
C	PROMPT FOR SCREEN CLEAR ON TERMINAL
C
	CALL PLOT(0.,8.,-3)
	CALL PLOTVT(0.0,-8.,-3)
	CALL CTERM(2)
C
C	MORE DATA (RANDOM) FOR THE SCATTER PLOT
C
	DO 6 I=1,25
		X2(I,1)=RAN(IS)*.5+1.
		X2(I,2)=RAN(IS)-.5
		Y2(I,1)=RAN(IS)*.3+1.
		Y2(I,2)=RAN(IS)*2.-.1
C
C	COMPUTE STATISTICS OF RANDOM VALUES
C
		XCENTER1=XCENTER1+X2(I,1)/25.
		YCENTER1=YCENTER1+Y2(I,1)/25.
		XRMS1=XRMS1+X2(I,1)**2/25.
		YRMS1=YRMS1+Y2(I,1)**2/25.
		XCENTER2=XCENTER2+X2(I,2)/25.
		YCENTER2=YCENTER2+Y2(I,2)/25.
		XRMS2=XRMS2+X2(I,2)**2/25.
		YRMS2=YRMS2+Y2(I,2)**2/25.
		XY1=XY1+X2(I,1)*Y2(I,1)/25.
		XY2=XY2+X2(I,2)*Y2(I,2)/25.
6	CONTINUE
C
C	COMPUTE STATISTICS
C
	XRMS1=XRMS1-XCENTER1**2
	YRMS1=YRMS1-YCENTER1**2
	XRMS2=XRMS2-XCENTER2**2
	YRMS2=YRMS2-YCENTER2**2
	XY1=XY1-XCENTER1*YCENTER1
	XY2=XY2-XCENTER2*YCENTER2
C
C	EXAMPLE OF USING SCATPL WITH TWO SET OF DATA AND LINEAR/LINEAR AXIES
C
	CALL SCATPL(X2,Y2,2,25,-10014,ICOL,.1,8.,5.,'X AXIS',-6,'Y AXIS',-6,
     $		'SCATPL',-6,D1,D2,D3,D4,ICOL)
C
C	LET'S ADD A ELLIPSE TO INDICATE THE GROUPINGS AND ALSO TO ILLUSTRATE
C	HOW TO PLOT AFTER A MASTER ROUTINE CALL.  WE WILL USE THE PLOTTING
C	SCALE FACTORS COMPUTED IN SCATPL TO CONVERT NORMAL UNITS INTO
C	PLOTTING UNITS.
C
C	PUT TERMINAL SCREEN BACK INTO PLOT MODE, CHANGE COLOR AND
C	PLOT AN ELLIPSE
C
	CALL CTERM(-1)
	CALL PLOT(10.,0.,0)
	XP=(XCENTER1-XMR)/DXR
	YP=(YCENTER1-YMR)/DYR
	CALL COVARIT(XRMS1,YRMS1,XCENTER1,YCENTER1,XY1,T1)
	SMAJ=SQRT(XRMS1)/DXR
	SMIN=SQRT(YRMS1)/DYR
	CALL ELLIPSE(XP,YP,SMAJ,SMIN,T1,0.,360.)
	CALL PLOT(0.,0.,3)
C
C	DASHED LINE
C
	CALL NEWPEN(3)
	CALL PLOT(1.,0.,0)
	CALL RECT(XP-SMAJ,YP-SMAJ,XP+SMAJ,YP+SMAJ)
	XP=(XCENTER2-XMR)/DXR
	YP=(YCENTER2-YMR)/DYR
	CALL COVARIT(XRMS2,YRMS2,XCENTER2,YCENTER2,XY2,T2)
	SMAJ=SQRT(XRMS2)/DXR
	SMIN=SQRT(YRMS2)/DYR
C
C	CHANGE PEN TO DOTTED LINE FOR ELLIPSE THEN DASHED FOR BOX
C
	CALL PLOT(0.,0.,3)
	CALL NEWPEN(1)
	CALL ELLIPSE(XP,YP,SMAJ,SMIN,T2,0.,360.)
	CALL NEWPEN(5)
	CALL RECT(XP-SMIN,YP-SMAJ,XP+SMIN,YP+SMAJ)
	CALL PLOT(0.,0.,3)
C
C	RESTORE PEN TYPE TO SOLID, PROMPT FOR TERMINAL SCREEN CLEAR
C	AND MOVE ORIGINS
C
	CALL NEWPEN(0)
	CALL CTERM(2)
	CALL PLOT(8.,-8.,-3)
	CALL PLOTVT(-8.,8.,-3)
C
C	SET UP LINE TYPE ARRAY FOR CONTOURS
C
	DO 431 I=1,255
		ILINE(I)=MOD(I-1,10)
431	CONTINUE
C
C	EXAMPLE OF A SIMPLE CONTOUR PLOT USING THE MOST ROBUST
C	CONTOURING ALGORITHM (WHICH ALSO REQUIRES ALOT OF PEN MOTIONS)
C
	CALL CNTRPLT(D,25,25,25,25,-15,-1.,1.,-10054,5.,5.,
     $		'X TITLE',7,'Y TITLE',7,
     $		'CNTRPLT',-107,3.,10.,1.,20.,ICOL,ILINE)
C
C	PROMPT FOR TERMINAL SCREEN CLEAR AND MOVE ORIGINS
C
	CALL CTERM(2)
	CALL PLOT(1.8,6.5,-3)
	CALL PLOTVT(0.,-6.5,-3)
C
C	NOW PLOT 3-D SURFACE USING SLICES WITH AXIS
C
	CALL VAX3DX(D,25,25,25,25,25.,15.,6.,3.8,5.,-10001,-11,
     $		'VAX3DX X TITLE',14,-10.,10.,4,0,4,-.15,1,.1,
     $		'VAX3DX Y TITLE',14,1,0,3,-.15,1,.1,
     $		'Z TITLE',7,-1.,1.,3,2,2,-.15,1,.1,-1.,1.,ICOL)
C
C	ADD A LABEL AFTER MASTER ROUTINE CALL
C
	CALL CTERM(-1)
	CALL SYMBOL(0.5,1.0,.25,'VAX3DX',0.,6,-1)
C
C	NOTE THE PEN UP TO FORCE LAST PART OF OUTPUT TO TERMINAL BEFORE
C	THE PROMPT FOR SCREEN CLEAR COMMAND
C
	CALL PLOT(0.,0.,3)
	CALL CTERM(2)
C
C	MOVE ORIGINS
C
	CALL PLOT(4.2,-6.5,-3)
	CALL PLOTVT(-6.,6.5,-3)
C
C	MORE DATA TO LOOK NICE
C
	DO 25 I=1,125
		X(I)=10.*SIN(FLOAT(I)*3.14/30.)
 25	CONTINUE
C
C	PLOT A HISTOGRAM WITH THE MEAN AND STANDARD DEVIATION SHOWING
C
	CALL PHIST(X,30,'Histogram',-9,6.,5.,'PHIST Subtitle',14,'X TITLE ',
     $		8,-1.,1.,10.,-10001,1,0.,.4,ICOL)
C
C	PROMPT FOR SCREEN CLEAR AND MOVE ORIGINS
C	PUT NEXT PLOT ON NEXT PAGE
C
	CALL PLOT(-14.,0.,-3)
	CALL PLOTVT(14.,0.,-3)
	CALL CTERM(2)
	CALL RTERM(2)
	CALL NEWPAGE
C
C	PLOT 3D CONTOUR PLOT
C
	CALL CNT3DX(D,25,25,25,25,25.,15.,6.,3.4,5.,
     $		10,-1.,1.,1,-10001,-11,
     $		'CNT3DX X TITLE',14,-10.,10.,4,0,4,-.15,1,.1,
     $		'CNT3DX Y TITLE',14,1,0,3,-.15,1,.1,
     $		'Z TITLE',7,-1.,1.,3,2,2,-.15,1,.1,-1.,1.,ICOL)
C
C	ADD LABEL AFTER MASTER ROUTINE CALL
C
	CALL CTERM(-1)
	CALL SYMBOL(0.,0.,.2,'CNT3DX',0.,6,-1)
C
C	MOVE ORIGIN
C
	CALL PLOT(10.,0.,-3)
	CALL PLOTVT(-10.,0.,-3)
C
C	PROMPT FOR TERMINAL SCREEN CLEAR
C
	CALL CTERM(2)
C
C	NOW PLOT 3-D SURFACE USING 3-D MESH (HIDDEN LINES) WITH A
C	CONTOUR PLOT AND INTERCONNECT PATH
C
	DO 42 I=1,25
		XX(I)=-1.+(I-1)*.2
		J=(I-1)*3+1
		IP(J)=2
		IP(J+1)=I
		IP(J+2)=I
		IF (I.GT.12) IP(J+1)=12
		IP(J+3)=0
42	CONTINUE
	ILINE(1)=1
C
	CALL CVAX3D(D,25,25,25,25,30.,40.,6.,3.4,4.,-10002,
     $		21,2.75,11,XX,-1,-3,ILINE,IP,'X TITLE',7,0.0,10.,
     $		'Y TITLE',7,'Z TITLE',7,-5.,5.,D1,D2,ICOL)
C
C	RESTORE LINETYPE AND ADD LABEL AFTER MASTER ROUTINE CALL
C
	CALL NEWPEN(0)
	CALL CTERM(-1)
	CALL SYMBOL(-.255,0.,.25,'CVAX3D',90.,6,-1)
C
C	PROMPT FOR SCREEN CLEAR, NOTE PENUP AFTER SYMBOL
C	CALL TO FORCE OUTPUT TO SCREEN BEFORE CTERM CALL
C
	CALL PLOT(0.,0.,3)
	CALL CTERM(2)
	CALL RTERM(2)
	CALL NEWPAGE
C
C	MOVE ORIGINS
C
	CALL PLOT(-10.,0.,-3)
	CALL PLOTVT(10.,0.,-3)
C
C	NOW PLOT 3-D HISTOGRAM WITH HIDDEN LINES REMOVED, WITH AXIS, ETC.
C
	CALL MVAX3D(D,25,25,25,25,30.,40.,6.,3.,4.,-10042,-1,
     $		'MVAX3DX X TITLE',15,-2.,2.,
     $		'MVAX3DX Y TITLE',15,
     $		'Z TITLE',7,-1.,1.,-1.,1.,ICOL)
C
C	ADD LABEL AFTER MASTER ROUTINE CALL
C
	CALL CTERM(-1)
	CALL SYMBOL(0.,0.,.25,'MVAX3DX',0.,6,-1)
C
C	PROMPT FOR TERMINAL SCREEN CLEAR AND MOVE ORIGINS
C
	CALL PLOT(0.,8.,-3)
	CALL PLOTVT(0.,-8.,-3)
	CALL CTERM(2)
C
C	NOW FOR AN EXAMPLE OF GLPLOT WITH FORMATTED AXIES
C
	CALL GLPLOT(X,Y2,2,25,2,15,-10064,3,7.,5.,6.0102,-.15,5.02,'X Axis',
     $		6,4.05,.2,6.03,'Y Axis',6,'GLPLOT Title',-112,
     $		D1,D2,D3,D4,ICOL,ILINE)
C
C	PROMPT FOR TERMINAL SCREEN CLEAR AND MOVE ORIGINS
C
	CALL CTERM(2)
	CALL PLOT(10.,-8.,-3)
	CALL PLOTVT(-10.,8.,-3)
C
C	SET UP SOME DATA TO PLOT USING EXISTING ARRAYS
C
	DO 30 I=1,25
C
C	DETERMANTISTIC FUNCTION FOR SIESPL
C
		X(I)=I
		Y2(I,1)=SIN(I*.9)
		Y2(I,2)=COS(I*2.)
C
C	FUNCTION PLUS ERROR BARS TO ILLUSTRATE SPLOTS
C
		Y3(I,1)=SIN(I*.4)
		Y3(I,2)=Y3(I,1)-0.5*RAN(IS)
		Y3(I,3)=Y3(I,1)+0.7*RAN(IS)
30	CONTINUE
	XX(1)=0.
	XX(2)=1.4
C
C	AN EXAMPLE OF SIESPL
C
	CALL SEISPL(X,Y2,XX,2,25,2,20,-10034,-6,-.1,0.,6.,4.,'X Title',7,
     $		'Y Title',7,'SIESPL',-6,D1,D2,D3,D4,ICOL)
C
C	PROMPT FOR TERMINAL SCREEN CLEAR AND MOVE ORIGINS
C
	CALL CTERM(2)
	CALL PLOT(0.,8.,-3)
	CALL PLOTVT(0.,-8.,-3)
C
C	AN EXAMPLE OF SPLOTS
C
	CALL SPLOTS(X,Y3,3,25,1,25,-10024,11,.22,6.,4.,'X Title',7,
     $		'Y Title',7,'SPLOTS',6)
C
C	PROMPT FOR TERMINAL SCREEN CLEAR AND MOVE ORIGINS
C	NEWPAGE ON METAFILE
C
	CALL CTERM(2)
	CALL RTERM(2)
	CALL PLOT(-10.,-8.,-3)
	CALL PLOTVT(10.,8.,-3)
	CALL NEWPAGE
C
C	AN EXAMPLE OF HIST3D  FIRST WE SET UP THE 3D TRANSFORMATION VALUES
C
      	DV=100.
      	PSI=135.
      	PHI=10.
      	THETA=45.
C
C	PLOT A SIMPLE TITLE
C
	CALL CTERM(-1)
	CALL SYMBOL(0.,0.,.3,'HIST3D',0.,6,-1)
C
	CALL HIST3D(D,25,25,10,10,PSI,PHI,THETA,DV,1.,5.,5.,5.,
     $		-10012,1,
     $	'X',1,-50.,50.,3.01,-0.25,-90.,6.02,
     $	'Y',1,-10.,10.,3.04,0.2,0.,6.02,
     $	'Z',1,4.,.15,-90.,6.02,0.,2.,ICOL)
C
C	PROMPT FOR TERMINAL SCREEN CLEAR AND MOVE ORIGINS
C
	CALL CTERM(2)
	CALL PLOT(10.,0.,-3)
	CALL PLOTVT(-10.,0.,-3)
C
C	AN EXAMPLE OF T3DH
C
	CALL CTERM(-1)
	CALL SYMBOL(0.,0.,.3,'T3DH',0.,4,-1)
C
	CALL T3DH(D,25,25,20,20,PSI,PHI,THETA,DV,5.,5.,5.,
     $		-10012,01,
     $		'X',1,-50.,50.,3.01,-0.25,-90.,6.02,
     $		'Y',1,-10.,10.,3.04,0.2,0.,6.02,
     $		'Z',1,4.,.15,-90.,6.02,0.,2.,ICOL)
C
C	PROMPT FOR TERMINAL SCREEN CLEAR AND MOVE ORIGINS
C
	CALL CTERM(2)
	CALL PLOT(-10.,9.,-3)
	CALL PLOTVT(10.,-9.,-3)
C
C	CREATE SOME RANDOMLY PLACED 3D POINTS
C
	IS=12423117
	DO 432 I=1,100
		XX(I)=RAN(IS)*4.
		YY(I)=RAN(IS)*4.
		XX2(I)=COS(XX(I))*COS(YY(I))
432	CONTINUE
C
C	CHOOSE SOME CONTOUR PARAMETERS
C
	NCNTRS=10
	DO 433 I=1,NCNTRS
		YY2(I)=2.*(I-1)/FLOAT(NCNTRS-1)-1.
		ILINE(I)=MOD(I-1,7)
433	CONTINUE
	ILINE(3)=ILINE(3)+20
	ILINE(4)=ILINE(-1)
C
C AN EXAMPLE OF CNTLN
C
	CALL CNTLN(XX,YY,XX2,100,5.,5.,-10004,NCNTRS,YY2,33,
     $	'X',1,2.01,-0.2,6.02,
     $	'Y',1,3.04,0.2,6.02,
     $	'CNTLN',5,0.,4.,0.,4.,ICOL,ILINE)
C
C	NOW PLOT THE TRANGULATION OF THE POINTS FOR CNTLN WITH DASHED LINE
C
C	CALL NEWPEN(3)
C	CALL CNTLN(XX,YY,XX2,100,5.,5.,-10002,NCNTRS,YY2,-133,
C     $	'X',1,2.01,-0.2,6.02,
C     $	'Y',1,3.04,0.2,6.02,
C     $	'CNTLN',0,0.,4.,0.,4.,ICOL(5))
C	CALL NEWPEN(0)
C
C	PROMPT FOR TERMINAL SCREEN CLEAR AND MOVE ORIGINS
C
	CALL CTERM(2)
	CALL PLOT(7.,-2.,-3)
	CALL PLOTVT(-7.,2.,-3)
C
C	AN EXAMPLE OF TRIG3DH
C
	PSI=20
	PHI=10
	THETA=35
	DV=9999.
	CALL CTERM(-1)
	CALL SYMBOL(0.,0.,.3,'TRIG3DH',0.,7,-1)
	CALL TRIG3DH(XX,YY,XX2,100,PSI,PHI,THETA,DV,5.,5.,5.,
     $		-10012,333,
     $		'X',1,3.02,-0.25,0.,6.02,
     $		'Y',1,3.04,0.2,0.,6.02,
     $		'Z',1,4.01,.15,-90.,6.02,
     $  	0.,4.,0.,4.,-1.,1.,ICOL)
C
C	CLOSE UP PLOT PACKAGE
C
	CALL CTERM(2)
	CALL PLOTND
C
C	ALL DONE
C
	STOP
	END
C
C
	SUBROUTINE COVARIT(XRMS,YRMS,XCENTER,YCENTER,XY,T)
C
C	SUBROUTINE TO COMPUTE COVARIANCE MATRIX ROTATION ANGLE
C
	R=(XRMS+YRMS)**2-4*(XRMS*YRMS-XY**2)
	XY1=XY
	T=0.0
	IF (XY.EQ.0.0) GOTO 10
C
C	TEST FOR BAD COVARIANCE MATRIX
C
	IF (R.LT.0) THEN
		XY1=SQRT(XRMS*YRMS-(XRMS+YRMS)**2/4.)
		EV1=(XRMS+YRMS)/2.
		EV2=EV1
	ELSE
		EV1=(XRMS+YRMS+SQRT(R))/2.
		EV2=(XRMS+YRMS-SQRT(R))/2.
	ENDIF
	X=SQRT((YRMS-EV1)**2/(XY1**2+(YRMS-EV1)**2))
	Y=SQRT(XY1**2/(XY1**2+(YRMS-EV1)**2))
	T=ATAN2(Y,X)*180./3.141592654
	XRMS=EV1
	YRMS=EV2
10	RETURN
	END
